﻿using DevExpress.XtraEditors;
using DevExpress.XtraTreeList.Nodes;
using DLL;
using Newtonsoft.Json;
using NursingDocumentInfoSystem;
using NursingDocumentInfoSystem.ClinicRecord;
using NursingFormSystem.BilirubinMonitoring;
using NursingFormSystem.BloodGlucoseMeter;
using NursingFormSystem.BloodGlucoseMeterNICU;
using NursingFormSystem.BloodGlucoseMonitoring;
using NursingFormSystem.Common;
using NursingFormSystem.CVP;
using NursingFormSystem.FallNursingMeasuresToPrevent;
using NursingFormSystem.FallRiskAssessment;
using NursingFormSystem.FallsDropBed;
using NursingFormSystem.HandoverSlip;
using NursingFormSystem.HealthEducationRecordSheet;
using NursingFormSystem.HealthEducationRSFNU;
using NursingFormSystem.HospitalizedChildren;
using NursingFormSystem.Hypoglycemia;
using NursingFormSystem.InfantBaby;
using NursingFormSystem.KnowingAgreeBook;
using NursingFormSystem.Model;
using NursingFormSystem.NeonatalObservationTable;
using NursingFormSystem.NursingRecordSheet;
using NursingFormSystem.NursingRecordsIntegration;
using NursingFormSystem.NursingSurgery;
using NursingFormSystem.NutritionalRisk;
using NursingFormSystem.Oxytocin;
using NursingFormSystem.Padua;
using NursingFormSystem.PICCBloodPurification;
using NursingFormSystem.PICCNursing;
using NursingFormSystem.PICCNursingConsent;
using NursingFormSystem.PICCNursingForm;
using NursingFormSystem.PICCNursingUpperLimb;
using NursingFormSystem.RiskAssessment;
using NursingFormSystem.SBAR;
using NursingFormSystem.Scale;
using NursingFormSystem.SingleDelivery;
using NursingFormSystem.SpecialPopulationAssessmentForm;
using NursingFormSystem.TubeDrawing;
using ShiftProject.Transfusion;
using SQLDLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Web;
using System.Windows.Forms;

namespace NursingFormSystem
{
    public partial class MainForm : DevExpress.XtraEditors.XtraForm
    {
        #region 变量声明
        NurFormsService.NursingForm formService = new NurFormsService.NursingForm();
        NursingFormSystem.WebReference2.FunctionAndPermissions WebService = new NursingFormSystem.WebReference2.FunctionAndPermissions();
        string[] user;//当前的登录信息
        DataTable patients = null;
        string[] curpatient = new string[18];//选前选中患者信息，数组，传入调用的form中
        Form1 form1;//住院患者护理评估单 只有这个特殊需要放到成员变量
        #endregion
        #region 数据加载和事件
        public MainForm(string[] UserParam)
        {
            InitializeComponent();
            user = UserParam;
            InitData();

            BindControl();
            BindInfo();

        }
        /// <summary>
        /// 初始化相关在院-历史单选框，以及患者信息下拉框按钮；
        /// </summary>
        private void InitData()
        {
            //radioGroup_status.SelectedIndexChanged += radioGroup_status_SelectedIndexChanged;//注册监听事件；
            //comboBox_patients.SelectedIndexChanged += comboBox_patients_SelectedIndexChanged;//注册监听事件；
            radioGroup_status.SelectedIndex = 0;//初始值设置为在院
            comboBox_patients.Properties.DropDownRows = 15;//设置初始化的下拉值
            comboBox_patients.Properties.DropDownItemHeight = 20;//下拉框的高度
            if (radioGroup_status.SelectedIndex == 0)//判断是否选中的是第一个焦点-在院，获取在院患者并绑定；
            {
                comboBox_patients.Properties.Items.Clear();
                patients = WebService.getDepartmentCodePatients(user[2]).D;
                if (patients != null)
                {
                    foreach (DataRow row in patients.Rows)
                    {
                        comboBox_patients.Properties.Items.Add(row["PATIENT_NAME"] + "   " + row["BED_NO"] + "床");
                    }
                    comboBox_patients.SelectedIndex = 0;
                }
            }
        }

        /// <summary>
        /// 在院-历史的状态变化事件,影响患者列表；
        /// </summary>
        private void radioGroup_status_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (radioGroup_status.SelectedIndex == 0)//判断是否选中的是第一个焦点-在院，获取在院患者并绑定；
            {
                comboBox_patients.Properties.Items.Clear();
                patients = WebService.getDepartmentCodePatients(user[2]).D;
                if (patients != null)
                {
                    foreach (DataRow row in patients.Rows)
                    {
                        comboBox_patients.Properties.Items.Add(row["PATIENT_NAME"] + "   " + row["BED_NO"] + "床");
                    }
                    comboBox_patients.SelectedIndex = 0;
                }
            }
            else//表明是历史患者，获取历史患者信息
            {
                int history_day = 0;
                DataTable dt_day = Base.GetConfigVal("DaysOfHistoricalPatients");
                if (dt_day != null && dt_day.Rows.Count > 0 && dt_day.Rows[0]["config_value"] != null)
                {
                    history_day = Convert.ToInt32(dt_day.Rows[0]["config_value"] + "");
                }
                DateTime startdt = DateTime.Now.AddDays(history_day).Date;
                DateTime enddt = DateTime.Now;
                comboBox_patients.Properties.Items.Clear();
                patients = WebService.GetPatientInfoByType(startdt, enddt, 1, "", user[2], false).D;
                if (patients != null)
                {
                    foreach (DataRow row in patients.Rows)
                    {
                        comboBox_patients.Properties.Items.Add(row["PATIENT_NAME"] + "   " + row["BED_NO"] + "床");
                    }
                }
                DataTable patients01 = WebService.GetPatientInfoByType(startdt, enddt, 3, "", user[2], false).D;
                if (patients01 != null)
                {
                    foreach (DataRow row in patients01.Rows)
                    {
                        comboBox_patients.Properties.Items.Add(row["PATIENT_NAME"] + "(转)" + "   " + row["BED_NO"] + "床");
                    }
                }
                if (patients01 != null && patients != null)
                {
                    patients.Merge(patients01);
                }
                else if (patients01 != null && patients == null)
                {
                    patients = patients01;
                }
                comboBox_patients.SelectedIndex = 0;
            }
        }

        /// <summary>
        ///点击患者的时候的监听事件：影响护理表单列表，看当前患者有多少已经录入的列表，进行变色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBox_patients_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str = comboBox_patients.SelectedText.ToString();//获取选中的项
            GetCurPatientInfo();
            var rootNode = treeListNurFrm.Nodes.FirstNode;
            if (rootNode != null)
            {
                rootNode.Selected = true;
                rootNode.Expanded = true;
            }
        }

        /// <summary>
        /// 显示窗体 
        /// </summary>
        /// <param name="frm">要显示的窗体实例</param>
        private void ShowForm(XtraForm frm)
        {
            frm.MaximizeBox = true;
            frm.TopLevel = false;
            frm.FormBorderStyle = FormBorderStyle.None;
            //frm.BackColor = this.panelControl1.BackColor;
            frm.Dock = DockStyle.Fill;
            this.panelControl1.Controls.Clear();
            this.panelControl1.Controls.Add(frm);
            frm.Show();
        }
        private void ShowForm(Form frm)
        {
            frm.MaximizeBox = true;
            frm.TopLevel = false;
            frm.FormBorderStyle = FormBorderStyle.None;
            //frm.BackColor = this.panelControl1.BackColor;
            frm.Dock = DockStyle.Fill;
            this.panelControl1.Controls.Clear();
            this.panelControl1.Controls.Add(frm);
            frm.Show();
        }
        #endregion

        #region 获取当前选中患者的信息
        private void GetCurPatientInfo()
        {
            Array.Clear(curpatient, 0, curpatient.Length);//清空数组
            DataRow row = patients.NewRow();
            if (comboBox_patients.SelectedIndex < 0) return;
            row = patients.Rows[comboBox_patients.SelectedIndex];
            curpatient[0] = row["PATIENT_ID"].ToString().Trim();//ID
            curpatient[1] = row["VISIT_ID"].ToString().Trim();//住院次数
            curpatient[2] = row["PATIENT_NAME"].ToString().Trim();//姓名
            curpatient[3] = row["SEX"].ToString().Trim();//性别
            if (curpatient[3].Equals("1")) curpatient[3] = "男";
            if (curpatient[3].Equals("2")) curpatient[3] = "女";
            curpatient[4] = row["AGE"].ToString().Trim();//年龄
            curpatient[5] = row["BED_NO"].ToString().Trim();//床号
            curpatient[6] = row["IN_DATE"].ToString().Trim();//入院时间
            curpatient[7] = row["IN_DEPARTMENT_DATE"].ToString().Trim();//入科时间
            if (App_Code.Common.HospitalIndex == 2)
                curpatient[7] = row["IN_DATE"].ToString().Trim();//入院时间
            curpatient[8] = row["DEPARTMENT_ID"].ToString().Trim();//科室ID
            curpatient[9] = row["DEPARTMENT_NAME"].ToString().Trim();//科室名称
            curpatient[10] = row["NURSE_CELL_CODE"].ToString().Trim();//病区ID
            curpatient[11] = row["NURSE_CELL_NAME"].ToString().Trim();//病区名称
            curpatient[12] = row["NATIONALS"].ToString().Trim();//民族
            curpatient[13] = row["EDUCATION"].ToString().Trim();//教育程度
            curpatient[14] = row["JOB"].ToString().Trim();//工作
            curpatient[15] = row["MARRIAGE"].ToString().Trim();//婚姻
            curpatient[16] = row["CONTACT_PHONE"].ToString().Trim();//联系电话
            curpatient[17] = row["DIAGNOSE"].ToString().Trim();//诊断信息
        }
        #endregion



        #region 树形菜单相关事件
        private void BindControl()
        {
            #region 设置treeList的属性
            DevExpress.XtraTreeList.Columns.TreeListColumn colNode = new DevExpress.XtraTreeList.Columns.TreeListColumn();
            colNode.Name = "护理文书";
            colNode.Caption = "护理文书";
            colNode.FieldName = "NodeText";
            colNode.VisibleIndex = 0;
            colNode.Visible = true;
            colNode.OptionsColumn.AllowEdit = false;
            colNode.OptionsColumn.AllowMove = false;
            colNode.OptionsColumn.AllowMoveToCustomizationForm = false;
            colNode.OptionsColumn.AllowSort = false;
            colNode.OptionsColumn.FixedWidth = false;
            colNode.OptionsColumn.ReadOnly = true;
            colNode.OptionsColumn.ShowInCustomizationForm = true;
            colNode.MinWidth = 300;
            colNode.Width = 300;
            treeListNurFrm.KeyFieldName = "Id";
            treeListNurFrm.ParentFieldName = "ParentId";
            treeListNurFrm.Columns.Clear();
            treeListNurFrm.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { colNode });
            treeListNurFrm.Appearance.FocusedCell.BackColor = System.Drawing.Color.LightSteelBlue;
            treeListNurFrm.Appearance.FocusedCell.BackColor2 = System.Drawing.Color.SteelBlue;
            treeListNurFrm.Appearance.FocusedCell.Options.UseBackColor = true;
            treeListNurFrm.Appearance.FocusedCell.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            treeListNurFrm.LookAndFeel.UseDefaultLookAndFeel = false;
            treeListNurFrm.LookAndFeel.UseWindowsXPTheme = false;
            treeListNurFrm.OptionsView.ShowIndicator = false;
            treeListNurFrm.OptionsView.ShowIndentAsRowStyle = true;
            treeListNurFrm.OptionsView.ShowButtons = true;
            treeListNurFrm.OptionsView.ShowColumns = false;
            treeListNurFrm.OptionsView.AutoWidth = false;
            treeListNurFrm.BestFitColumns();
            treeListNurFrm.HorzScrollVisibility = DevExpress.XtraTreeList.ScrollVisibility.Always;
            #endregion
        }

        private void BindInfo()
        {
            #region 护理单列表数据
            //新建list数据源
            List<FormTreeNode> data = new List<FormTreeNode>();
            string areaCode = this.user[2];
            string sql = string.Format(" SELECT * FROM BNNursingDocsSystem_Develop.dbo.NursingFormType(NOLOCK) SELECT * FROM BNNursingDocsSystem_Develop.dbo.NursingForm(NOLOCK) WHERE AreaId='{0}' AND [Enable]=1 ORDER BY Sort ", areaCode);
            DataSet ds = SqlHelper.ExecuteDataset(sql);
            DataTable dtp = ds.Tables[0];
            DataTable dtc = ds.Tables[1];
            data.Add(new FormTreeNode() { Id = "0", ParentId = String.Empty, NodeText = "默认" });
            for (int i = 0; i < dtp.Rows.Count; i++)
            {
                data.Add(new FormTreeNode() { Id = dtp.Rows[i]["pkid"].ToString().Trim(), ParentId = String.Empty, NodeText = dtp.Rows[i]["nursingFormTypeName"].ToString().Trim() });
            }
            for (int i = 0; i < dtc.Rows.Count; i++)
            {
                string nurFormTypeId = string.IsNullOrEmpty(dtc.Rows[i]["NursingFormTypeId"].ToString().Trim()) ? "0" : dtc.Rows[i]["NursingFormTypeId"].ToString().Trim();
                data.Add(new FormTreeNode() { Id = dtc.Rows[i]["FormId"].ToString().Trim(), ParentId = nurFormTypeId, NodeText = dtc.Rows[i]["FormName"].ToString().Trim() });
            }
            treeListNurFrm.DataSource = data;
            //刷新数据
            treeListNurFrm.RefreshDataSource();
            //全部展开
            treeListNurFrm.ExpandAll();
            #endregion
        }

        /// <summary>
        /// 绑定图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeListNurFrm_CustomDrawNodeImages(object sender, DevExpress.XtraTreeList.CustomDrawNodeImagesEventArgs e)
        {
            if (e.Node == null) return;
            TreeListNode node = e.Node;
            string pid = node.GetValue("ParentId").ToString();
            if (string.IsNullOrEmpty(pid))
                e.SelectImageIndex = 0;
            else
                e.SelectImageIndex = 1;
        }

        /// <summary>
        /// 获取选中的FormId
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeListNurFrm_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            var FormTypeId = treeListNurFrm.FocusedNode.GetValue("ParentId").ToString();
            var FormId = treeListNurFrm.FocusedNode.GetValue("Id").ToString();
            if (string.IsNullOrEmpty(FormTypeId))
            {
                if (e.Node.Expanded)
                {
                    e.Node.Nodes.TreeList.FindNodeByID(e.Node.Id).Expanded = false;
                }
                else
                {
                    e.Node.ExpandAll();
                }
                return;
            }
            if (string.IsNullOrEmpty(FormId) || Convert.ToInt32(FormId) <= 0) return;

            Tb_User loginUser = new Tb_User();
            loginUser.UserId = user[0];
            loginUser.UserName = user[1];
            loginUser.DepartmentCode = user[2];
            loginUser.DepartmentName = user[3];
            loginUser.JobTitle = user[4];
            loginUser.PositionTitle = user[5];
            PatientInfo patientInfo = new PatientInfo();
            DataRow row = patients.NewRow();
            if (comboBox_patients.SelectedIndex < 0) return;
            row = patients.Rows[comboBox_patients.SelectedIndex];
            patientInfo.PATIENT_ID = row["PATIENT_ID"].ToString().Trim();//ID
            patientInfo.PATIENT_NAME = row["PATIENT_NAME"].ToString().Trim();//姓名
            //患者ID特殊处理
            if (patientInfo.PATIENT_NAME.StartsWith("(婴") && !patientInfo.PATIENT_ID.Contains("$"))
            {
                string babyNum = patientInfo.PATIENT_NAME.Substring(2, 1);
                patientInfo.PATIENT_ID += ("$" + babyNum);
            }
            patientInfo.VISIT_ID = Convert.ToInt32(row["VISIT_ID"]);//住院次数                
            patientInfo.SEX = row["SEX"].ToString().Trim();//性别
            if (patientInfo.SEX.Equals("1")) patientInfo.SEX = "男";
            if (patientInfo.SEX.Equals("2")) patientInfo.SEX = "女";
            patientInfo.AGE = row["AGE"].ToString().Trim();//年龄
            if (row["AGE_DESC"] != DBNull.Value)
                patientInfo.AGE_DESC = row["AGE_DESC"].ToString().Trim();//年龄
            patientInfo.BED_NO = row["BED_NO"].ToString().Trim();//床号
            if (row["IN_DATE"] != DBNull.Value)
                patientInfo.IN_DATE = Convert.ToDateTime(row["IN_DATE"]);//入院时间
            if (row["IN_DEPARTMENT_DATE"] != DBNull.Value)
                patientInfo.IN_DEPARTMENT_DATE = Convert.ToDateTime(row["IN_DEPARTMENT_DATE"]);//入科时间
            if (App_Code.Common.HospitalIndex == 2)
                patientInfo.IN_DEPARTMENT_DATE = patientInfo.IN_DATE;//入院时间
            patientInfo.DEPARTMENT_ID = row["DEPARTMENT_ID"].ToString().Trim();//科室ID
            patientInfo.DEPARTMENT_NAME = row["DEPARTMENT_NAME"].ToString().Trim();//科室名称
            patientInfo.NURSE_CELL_CODE = row["NURSE_CELL_CODE"].ToString().Trim();//病区ID
            patientInfo.NURSE_CELL_NAME = row["NURSE_CELL_NAME"].ToString().Trim();//病区名称
            patientInfo.NATIONALS = row["NATIONALS"].ToString().Trim();//民族
            patientInfo.EDUCATION = row["EDUCATION"].ToString().Trim();//教育程度
            patientInfo.JOB = row["JOB"].ToString().Trim();//工作
            patientInfo.MARRIAGE = row["MARRIAGE"].ToString().Trim();//婚姻
            patientInfo.CONTACT_PHONE = row["CONTACT_PHONE"].ToString().Trim();//联系电话
            patientInfo.DIAGNOSE = row["DIAGNOSE"].ToString().Trim();//诊断信息
            if (row["ID"] != DBNull.Value)
                patientInfo.ID = Convert.ToInt32(row["ID"]);//ID
            patientInfo.ALLERGY = row["ALLERGY"].ToString().Trim();//过敏史
            patientInfo.BLOOD_TYPE = row["BLOOD_TYPE"].ToString().Trim();//血型
            patientInfo.CHIEFCOMPLAINT = row["ChiefComplaint"].ToString().Trim();//主诉                 
            if (row["DATE_OF_BIRTH"] != DBNull.Value)
                patientInfo.DATE_OF_BIRTH = Convert.ToDateTime(row["DATE_OF_BIRTH"]);
            patientInfo.DOCTOR_ID = row["DOCTOR_ID"].ToString().Trim();
            patientInfo.DOCTOR_NAME = row["DOCTOR_NAME"].ToString().Trim();
            if (row["INSERT_TIME"] != DBNull.Value)
                patientInfo.INSERT_TIME = Convert.ToDateTime(row["INSERT_TIME"]);
            patientInfo.MEDICAL_TYPE = row["MEDICAL_TYPE"].ToString().Trim();
            patientInfo.NURSE_ID = row["NURSE_ID"].ToString().Trim();
            patientInfo.NURSE_NAME = row["NURSE_NAME"].ToString().Trim();
            patientInfo.NURSING = row["NURSING"].ToString().Trim();
            if (row["OUT_DATE"] != DBNull.Value)
                patientInfo.OUT_DATE = Convert.ToDateTime(row["OUT_DATE"]);
            if (row["PREPAY_COST"] != DBNull.Value)
                patientInfo.PREPAY_COST = Convert.ToDecimal(row["PREPAY_COST"]);//预付款
            patientInfo.STATUS = row["STATUS"].ToString().Trim();
            if (row["TOTAL_MONEY"] != DBNull.Value)
                patientInfo.TOTAL_MONEY = Convert.ToDecimal(row["TOTAL_MONEY"]);
            if (row["UPDATE_TIME"] != DBNull.Value)
                patientInfo.UPDATE_TIME = Convert.ToDateTime(row["UPDATE_TIME"]);
            patientInfo.UPDATE_USER = row["UPDATE_USER"].ToString().Trim();
            patientInfo.WZ_STATUS = row["WZ_STATUS"].ToString().Trim();

            #region 表单列表
            if (FormId == ((int)FormType.ZYHZHLPGD).ToString())
            {
                //住院患者护理评估单
                form1 = new Form1(user, curpatient);
                ShowForm(form1);
            }
            else if (FormId == ((int)FormType.NurseForm).ToString())
            {
                //临床护理记录单(神经科)
                HistorySheet historySheet = new HistorySheet(loginUser, patientInfo);
                ShowForm(historySheet);
            }
            else if (FormId == ((int)FormType.TempbedNursing).ToString())
            {
                //临床护理记录单(通用)
                NursingForm nursingForm = new NursingForm(user, curpatient);
                ShowForm(nursingForm);
            }
            else if (FormId == ((int)FormType.TempbedNursingCVP).ToString())
            {
                //临床护理记录单(心血管科)
                NursingFormXinXueGuan nursingForm = new NursingFormXinXueGuan(user, curpatient);
                ShowForm(nursingForm);
            }
            else if (FormId == ((int)FormType.PatientHandover).ToString())
            {
                //手术患者交接单
                HandoverSing handoverSing = new HandoverSing(loginUser, patientInfo);
                ShowForm(handoverSing);
            }
            else if (FormId == ((int)FormType.Knowing).ToString())
            {
                //特殊护理措施知情同意书
                AddAgreeBookNursing addAgreeBookNursing = new AddAgreeBookNursing(loginUser, patientInfo);
                ShowForm(addAgreeBookNursing);
            }
            else if (FormId == ((int)FormType.Transfuse).ToString())
            {
                //安全输血护理记录单
                RecordsSafeCare recordsSafeCare = new RecordsSafeCare(loginUser, patientInfo);
                ShowForm(recordsSafeCare);
            }
            else if (FormId == ((int)FormType.Extubation).ToString())
            {
                //住院患者非计划性拔管风险评估护理单
                ExtubationRiskNursingHistory extubationRiskNursingHistory = new ExtubationRiskNursingHistory(loginUser, patientInfo);
                ShowForm(extubationRiskNursingHistory);
            }
            else if (FormId == ((int)FormType.RiskSore).ToString())
            {
                //住院病人压疮风险评估单
                HistoryRiskSoreNursing historyRiskSoreNursing = new HistoryRiskSoreNursing(loginUser, patientInfo);
                ShowForm(historyRiskSoreNursing);
            }
            else if (FormId == ((int)FormType.PatientCare).ToString())
            {
                //病人护理分级表
                HierarchicalHistory hierarchicalHistory = new HierarchicalHistory(loginUser, patientInfo);
                ShowForm(hierarchicalHistory);
            }
            else if (FormId == ((int)FormType.Bloodsugar).ToString())
            {
                //血糖单
                BloodGlucForm bloodGlucForm = new BloodGlucForm(user, curpatient);
                ShowForm(bloodGlucForm);
            }
            else if (FormId == ((int)FormType.HealthEduForm).ToString())
            {
                //健康宣教管理
                HealthEducation healthEducation = new HealthEducation(user, curpatient);
                //HealthEducation healthEducation = new HealthEducation(user);
                ShowForm(healthEducation);
            }
            else if (FormId == ((int)FormType.FallDown).ToString())
            {
                //住院病人跌倒/坠床风险评估护理单
                FallsDropNursingHistory fallsDropNursingHistory = new FallsDropNursingHistory(loginUser, patientInfo);
                ShowForm(fallsDropNursingHistory);
            }
            else if (FormId == ((int)FormType.NursingPlanForm).ToString())//护理计划
            {
                //PlanFormList planFormList;//护理计划
                //planFormList = new PlanFormList(user, curpatient);
                //ShowForm(planFormList);
            }
            else if (FormId == ((int)FormType.SpaForm).ToString())//特殊人群单
            {
                //特殊人群单
                AddSPAF addSPAF = new AddSPAF(loginUser, patientInfo);
                ShowForm(addSPAF);
            }
            else if (FormId == ((int)FormType.FallFRA).ToString())
            {
                //住院患儿跌倒风险评估表
                HistoryFallRiskAssessment historyFallRiskAssessment = new HistoryFallRiskAssessment(loginUser, patientInfo);
                ShowForm(historyFallRiskAssessment);
            }
            else if (FormId == ((int)FormType.FallMTP).ToString())
            {
                //预防住院患儿跌倒集束化护理措施
                HistoryFallNursingMeasuresToPrevent historyFallNursingMeasuresToPrevent = new HistoryFallNursingMeasuresToPrevent(loginUser, patientInfo);
                ShowForm(historyFallNursingMeasuresToPrevent);
            }
            else if (FormId == ((int)FormType.Bilirubin).ToString())
            {
                //胆红素监测
                HistoryBilirubinMonitoring bilirubin = new HistoryBilirubinMonitoring(loginUser, patientInfo);
                ShowForm(bilirubin);
            }
            else if (FormId == ((int)FormType.BloodGlucoseMeter).ToString())
            {
                //血糖监测(PICU)
                HistoryBloodGlucoseMeter BloodGlucose = new HistoryBloodGlucoseMeter(loginUser, patientInfo);
                ShowForm(BloodGlucose);
            }
            else if (FormId == ((int)FormType.CVPS).ToString())
            {
                //中心静脉压
                HistoryCVD historyCVD = new HistoryCVD(loginUser, patientInfo);
                ShowForm(historyCVD);
            }
            else if (FormId == ((int)FormType.SheetSafeChkRecord).ToString())
            {
                //介入室手术/有创操作安全核查记录
                HistorySurgery historySurgery = new HistorySurgery(loginUser, patientInfo);
                ShowForm(historySurgery);
            }
            else if (FormId == ((int)FormType.BloodPurification).ToString())
            {
                //PICU血液净化治疗单
                HistoryPICCBloodPurification BloodPurification = new HistoryPICCBloodPurification(loginUser, patientInfo);
                ShowForm(BloodPurification);
            }
            else if (FormId == ((int)FormType.UpperLimbNursing).ToString())
            {
                //PICC护理记录单(上肢）
                HistoryUpperLimb historyUpperLimb = new HistoryUpperLimb(loginUser, patientInfo);
                ShowForm(historyUpperLimb);
            }
            else if (FormId == ((int)FormType.PICCWashPipeNursing).ToString())
            {
                //PICC护理记录单(冲管单)
                HistoryPICC historyPICC = new HistoryPICC(loginUser, patientInfo);
                ShowForm(historyPICC);
            }
            else if (FormId == ((int)FormType.BybyAndBaby).ToString())
            {
                //婴儿护理记录单
                HistoryInfantBaby historyInfantBaby = new HistoryInfantBaby(loginUser, patientInfo);
                ShowForm(historyInfantBaby);
            }
            else if (FormId == ((int)FormType.Childs).ToString())
            {
                //儿童护理评估单
                AddHospitalizedChildren addHospitalizedChildren = new AddHospitalizedChildren(loginUser, patientInfo);
                ShowForm(addHospitalizedChildren);
            }
            else if (FormId == ((int)FormType.Pabulum).ToString())
            {
                //住院患者营养风险筛查评估单
                HistoryNutritionalRisk historyNutritionalRisk = new HistoryNutritionalRisk(loginUser, patientInfo);
                ShowForm(historyNutritionalRisk);
            }
            else if (FormId == ((int)FormType.Fetation).ToString())
            {
                //待产、产程记录单
                GestationForm gestationForm = new GestationForm(loginUser, patientInfo);
                ShowForm(gestationForm);
            }
            else if (FormId == ((int)FormType.FetationAfter).ToString())
            {
                //婴儿产时产后记录单
                InfantProducAfterEdit InfantProducAfterEdit = new InfantBaby.InfantProducAfterEdit(loginUser, patientInfo);
                ShowForm(InfantProducAfterEdit);
            }
            else if (FormId == ((int)FormType.Oxytocins).ToString())
            {
                //催产素引产记录单
                HistoryOxytocin historyOxytocin = new HistoryOxytocin(loginUser, patientInfo);
                ShowForm(historyOxytocin);
            }
            else if (FormId == ((int)FormType.PaduaScore).ToString())
            {
                //栓塞症风险评估表
                PaduaEdit PaduaEdit = new PaduaEdit(loginUser, patientInfo);
                ShowForm(PaduaEdit);
            }
            else if (FormId == ((int)FormType.WrittenConsentNursing).ToString())
            {
                //PICC同意书2
                AddConsent addConsent = new AddConsent(loginUser, patientInfo);
                ShowForm(addConsent);
            }
            else if (FormId == ((int)FormType.PICCNursing).ToString())
            {
                //PICC护理记录单
                PICCNursingRecordForm PICCNursing = new PICCNursingRecordForm(loginUser, patientInfo);
                ShowForm(PICCNursing);
            }
            else if (FormId == ((int)FormType.Parturitions).ToString())
            {
                //分娩记录单
                AddSingleDelivery addSingleDelivery = new AddSingleDelivery(loginUser, patientInfo);
                ShowForm(addSingleDelivery);
            }
            else if (FormId == ((int)FormType.Hypoglycemiaing).ToString())
            {
                //低血糖统计
                HistoryHypoglycemia historyHypoglycemia = new HistoryHypoglycemia(loginUser, patientInfo);
                ShowForm(historyHypoglycemia);
            }
            else if (FormId == ((int)FormType.HandOverDuty).ToString())
            {
                //护士晨会SBAR交班记录单
                HistorySBAR historySBAR = new HistorySBAR(loginUser, patientInfo);
                ShowForm(historySBAR);
            }
            else if (FormId == ((int)FormType.HealthERecordS).ToString())
            {
                //健康教育记录单
                AddHealthEducationRecordSheet addHealthEducationRecordSheet = new AddHealthEducationRecordSheet(loginUser, patientInfo);
                ShowForm(addHealthEducationRecordSheet);
            }
            else if (FormId == ((int)FormType.NewSpaForm).ToString())
            {
                //特殊人群单--新(临时使用)
                NursingFormSystem.SpecialPopulationAssessmentFormNew.HistorySPAF addSPAF = new NursingFormSystem.SpecialPopulationAssessmentFormNew.HistorySPAF(loginUser, patientInfo);
                ShowForm(addSPAF);
            }
            else if (FormId == ((int)FormType.BloodGlucoseMeterNICU).ToString())
            {
                //18008 血糖监测(NICU)
                HistoryBloodGlucoseMeterNICU frm = new HistoryBloodGlucoseMeterNICU(loginUser, patientInfo);
                ShowForm(frm);
            }
            else if (FormId == ((int)FormType.BabyBornObserve).ToString())
            {
                //19004 新生儿观察表
                HistoryNeonatalObservationTable hnt = new HistoryNeonatalObservationTable(loginUser, patientInfo);
                ShowForm(hnt);
            }
            else if (FormId == ((int)FormType.HealthERecordBaby).ToString())
            {
                //10006 新生儿教育记录单
                AddHealthEducationRSFNU addRSFUN = new AddHealthEducationRSFNU(loginUser, patientInfo);
                ShowForm(addRSFUN);
            }
            else if (FormId == ((int)FormType.NursingRecordsIntegration).ToString())
            {
                //18009 PICC护理记录整合
                AddNursingRecordsIntegration frm = new AddNursingRecordsIntegration(loginUser, patientInfo);
                ShowForm(frm);
            }
            else if (FormId == ((int)FormType.TempBedRecordICU).ToString())
            {
                //icu 现场
                //string url = "http://172.29.102.132:91/ICUNuring/?patientId={0}&visit_id={1}&patient_name={2}&bed_no={3}&dep_id={4}&dep_name={5}&area_id={6}&area_name={7}&sex={8}&age={9}&nurse_name={10}";
                //icu 阿里云
                string url = "http://118.31.62.66:2995/ICUNuring/?patientId={0}&visit_id={1}&patient_name={2}&bed_no={3}&dep_id={4}&dep_name={5}&area_id={6}&area_name={7}&sex={8}&age={9}&nurse_name={10}";
                url = string.Format(url, patientInfo.PATIENT_ID, patientInfo.VISIT_ID, HttpUtility.UrlEncode(patientInfo.PATIENT_NAME), HttpUtility.UrlEncode(patientInfo.BED_NO), patientInfo.DEPARTMENT_ID, HttpUtility.UrlEncode(patientInfo.DEPARTMENT_NAME), patientInfo.NURSE_CELL_CODE, HttpUtility.UrlEncode(patientInfo.NURSE_CELL_NAME), HttpUtility.UrlEncode(patientInfo.SEX), HttpUtility.UrlEncode(patientInfo.AGE), HttpUtility.UrlEncode(loginUser.UserName));
                InspectionView dvb = new InspectionView(EnumHelper.GetDescription(FormType.TempBedRecordICU), url);
                dvb.ShowDialog();
                //ShowForm(dvb);
            }
            else
            {
                if (!string.IsNullOrEmpty(FormId) && Regex.IsMatch(FormId, @"^\d+$"))
                    MessageBox.Show("未知的表单ID formcode:" + FormId, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            #endregion
        }

        /// <summary>
        /// 设置字体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeListNurFrm_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            e.Appearance.BackColor = Color.White;
            Font f = new Font("宋体", 10, FontStyle.Regular);
            e.Appearance.Font = f;
        }
        #endregion
    }
}
